﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FriendsRequest.aspx.cs"
    Inherits="SonCa.SocialNetwork.Web.Friends.FriendsRequest" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#btnAcceptRpt').click(function () {
                var accountID = $(this).attr('class');
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "../Services/AjaxService.svc/AcceptFriends",
                    data: '{"accountID": "' + accountID + '"}',
                    dataType: "json",
                    success: function (data) {
                        $('#messages-list').load("../Friends/FriendsRequest.aspx");
                    },
                    error: function () { }
                });
            });

            // Reject
            $('#btnReject').click(function () {
                var accountID = $(this).attr('class');
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "../Services/AjaxService.svc/RejectFriends",
                    data: '{"accountID": "' + accountID + '"}',
                    dataType: "json",
                    success: function (data) {
                        $('#messages-list').load("../Friends/FriendsRequest.aspx");
                    },
                    error: function () { }
                });
            });

            var flag_loadAllFriend = true;

            $("#displayAllFriend").hide();

            $("#linkdisplayAllFriend").click(function () {
                $("#loading_allfriend").show();
                if (flag_loadAllFriend == true) {
                    $("#displayAllFriend").load("../Friends/DisplayAllFriend.aspx");
                    flag_loadAllFriend = false;
                }
                $("#loading_allfriend").hide();
                $("#displayAllFriend").slideToggle();                
            });
        });        
    </script>
</head>
<body>
    <form id="form14" runat="server">
        <div>
            <span class="arrow"></span>
            <ul class="small-files-list icon-mail" style="margin-bottom: 10px;width:330px">
                <asp:label id="lblMes" runat="server" visible="false"></asp:label>
                <asp:Repeater ID="rptMessages" runat="server">
                    <ItemTemplate>
                        <li>
                            <a href="../Personals/PersonalPage.aspx?otherAccountID=<%#Eval("AccountID") %>">
                                <asp:Image ID="imgMessage" runat="server" Width="32" Height="32" ImageUrl='<%#Eval("ImageUrl") %>' />
                                <strong><%# Eval("FullName") %></strong>
                            </a>đã chấp nhận lời mời kết bạn.
                        </li>
                    </ItemTemplate>
                </asp:Repeater>
                <asp:repeater id="rptFriendInvitation" runat="server">
                    <ItemTemplate>
			            <li>
				            <a href="#">
                                <asp:Image ID="imgFriendInvitation" runat="server" Width="32" Height="32" ImageUrl='<%#Eval("ImageUrl") %>' />
                                <strong><%# Eval("FullName") %></strong><br/>
					            <small>Có 1 bạn chung</small>
                            </a>
                            <input type="button" id="btnAcceptRpt" value="Đồng ý" class='<%# Eval("AccountID") %>' />
                            <input type="button" id="btnReject" value="Từ chối" class='<%# Eval("AccountID") %>' />
			            </li>
                    </ItemTemplate>
                </asp:repeater>
            </ul>
            <div id="messages-info" class="result-info">
                <a href="#" id="linkdisplayAllFriend">Có thể bạn biết những người này &raquo;</a>
                <div id="loading_allfriend" style="display:none;margin-top:10px" align="center"><img src="../img/loading.gif" alt="loading..." /></div>
                <div id="displayAllFriend"></div>                
            </div>            
        </div>
    </form>
</body>
</html>
